<script setup>
import { getOrderAPI } from '@/apis/order';
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import { useRouter } from 'vue-router';


const router = useRouter()
//获取订单数据
const route = useRoute()
const payInfo = ref({})
const getPayInfo = async () => {
  const res = await getOrderAPI(route.query.orderId)
  if (res.data === '') {
    router.push({
      path: '/'
    })
    ElMessage.error("热水太烫我不敢喝、人心太凉我不敢碰、不是你的你别敢动！")
  }
  payInfo.value = res.data
}
onMounted(() => getPayInfo())

</script>

<template>
  <div class="xtx-pay-page">
    <div class="container">
      <!-- 支付结果 -->
      <div class="pay-result">
        <span class="iconfont icon-querenx green" v-if="$route.query.payResult === 'true'"></span>
        <span class="iconfont icon-chahao1 red" v-else></span>
        <p class="tit" v-if="payInfo.payChannel !== null">支付{{$route.query.payResult === 'true'?'成功':'失败'}}</p>
        <p class="tit" v-else>货到付款申请成功</p>
        <p class="tip">我们将尽快为您发货，收货期间请保持手机畅通</p>
        <p>支付方式：
          <span v-if="payInfo.payChannel === 1">微信</span>
          <span v-else-if="payInfo.payChannel === 2">支付宝</span>
          <span v-else-if="payInfo.payChannel === 3">招商银行</span>
          <span v-else-if="payInfo.payChannel === 4">工商银行</span>
          <span v-else-if="payInfo.payChannel === 5">建设银行</span>
          <span v-else-if="payInfo.payChannel === 6">农业银行</span>
          <span v-else-if="payInfo.payChannel === 7">交通银行</span>
          <span v-else>货到付款</span>
        </p>
        <p>支付金额：<span>¥{{ payInfo.total?.toFixed(2) }}</span></p>
        <div class="btn">
          <el-button type="primary" style="margin-right:20px" @click="$router.push('/member/order')">查看订单</el-button>
          <el-button @click="$router.push('/')">进入首页</el-button>
        </div>
        <p class="alert">
          <span class="iconfont icon-tip"></span>
          温馨提示：捷贸云不会以订单异常、系统升级为由要求您点击任何网址链接进行退款操作，保护资产、谨慎操作。
        </p>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.pay-result {
  padding: 100px 0;
  background: #fff;
  text-align: center;
  margin-top: 20px;

  >.iconfont {
    font-size: 100px;
  }

  .green {
    color: #1dc779;
  }

  .red {
    color: $priceColor;
  }

  .tit {
    font-size: 24px;
  }

  .tip {
    color: #999;
  }

  p {
    line-height: 40px;
    font-size: 16px;
  }

  .btn {
    margin-top: 50px;
  }

  .alert {
    font-size: 12px;
    color: #999;
    margin-top: 50px;
  }
}
</style>